// 设备Api
import request from '@/utils/request'
import { AxiosPromise } from 'axios'
import { AdsBo, AdsVo } from '@/api/business/ads/types'

enum Api {
  list = '/ads/list',
  delete = '/ads/delete',
  batchDelete = '/ads/batchDelete',
  add = '/ads/add',
  edit = '/ads/edit',
  detail = '/ads/detail',
  optionSelect = '/ads/optionSelect',
  changeStatus = '/ads/changeStatus',
}

// 获取列表
export const adsList = (data: any): AxiosPromise<AdsVo[]> => {
  return request({
    url: Api.list,
    method: 'post',
    data,
  })
}

// 删除
export const adsDelete = (data: string) => {
  return request({
    url: Api.delete,
    method: 'post',
    data,
  })
}
// 批量删除
export const adsBatchDelete = (data: (string | number)[]) => {
  return request({
    url: Api.batchDelete,
    method: 'post',
    data,
  })
}

// 编辑、保存
export const adsSave = (data: AdsBo) => {
  return request({
    url: data.id ? Api.edit : Api.add,
    method: 'post',
    data,
  })
}

// 获取设备详情
export const adsDetail = (data: any) => {
  return request({
    url: Api.detail,
    method: 'post',
    data,
  })
}

// 获取选择框列表
export const optionSelect = (data: any) => {
  return request({
    url: Api.optionSelect,
    method: 'post',
    data: data,
  })
}

// 状态修改
export function changeStatus(id: string | number, status: number) {
  const data = {
    id,
    status,
  }
  return request({
    url: Api.changeStatus,
    method: 'post',
    data,
  })
}
